class Solution {
public:
    int dx[4] = { 0,0,1,-1 };
    int dy[4] = { 1,-1,0,0 };
    vector<vector<int>> highestPeak(vector<vector<int>>& Water)
    {
        int m = Water.size(), n = Water[0].size();
        queue<pair<int, int>> q;
        vector<vector<int>> dis(m, vector<int>(n, -1));
        for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) if (Water[i][j] == 1) q.push({ i,j }), dis[i][j] = 0;
        while (q.size())
        {
            auto [a, b] = q.front();
            q.pop();
            for (int u = 0; u < 4; u++)
            {
                int x = dx[u] + a, y = dy[u] + b;
                if (x >= 0 && x < m && y >= 0 && y < n && dis[x][y] == -1)
                {
                    dis[x][y] = dis[a][b] + 1;
                    q.push({ x,y });
                }
            }
        }
        return dis;
    }
};